<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserRelateTable extends Migration
{
    /**
     * 创建内外部用户关联表
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_relate', function (Blueprint $table) {
            //表属性
            $table->engine = 'InnoDB';
            $table->charset = 'utf8';
            $table->collation = 'utf8_general_ci';
            //表字段
            $table->integer('internal_uid')->comment('内部用户id');
            $table->integer('external_uid')->comment('外部用户id');
            //创建索引
            $table->index('internal_uid');
            $table->index('external_uid');
            $table->unique(['internal_uid','external_uid']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_relate');
    }
}
